<%@page import="business.manage.dictionary.DictArgument"%>
<%@page import="business.manage.dictionary.Dictionary"%>
<%@page import="common.database.bean.Page"%>
<%@page import="common.database.bean.CreatePageCode"%>
<%@page import="java.util.List"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
	+ request.getServerName() + ":" + request.getServerPort()
	+ path + "/";
	
	Page curPage = (Page)request.getAttribute("page");
	List<Dictionary> dictList = (List<Dictionary>)curPage.getResult();
	List<Dictionary> parentDictList = (List<Dictionary>)request.getAttribute("parentDictList");
	DictArgument da = (DictArgument)request.getAttribute("da");
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<link rel="stylesheet" href="<%=path%>/inc/css.css" type="text/css" />
</head>
<body>
<form action="<%=path %>/dict/list" name="PageForm" id="PageForm" method="post">
		<table width="100%" border=0 align=center cellpadding=2 cellspacing=1
			bordercolor="#799AE1" class=tableBorder>
			<tbody>
				<tr>
					<th align=center colspan=16 style="height: 23px">字典数据管理</th>
				</tr>
				<tr bgcolor="#DEE5FA">
					<td colspan="6" align="center" class=txlrow>&nbsp;</td>
				</tr>
				
				<tr bgcolor="#DEE5FA">
					<td colspan="4" align="left" class=txlrow>&nbsp;类别:
						<select name="pid">
							<option value="">-----</option>
							<%
								if(parentDictList.size()>0){
									for(int i=0;i<parentDictList.size();i++){
										Dictionary parent = parentDictList.get(i);
							%>

							<option value="<%=parent.getId() %>" <%if(parent.getId().equals(da.getPid())){ %>selected<%} %>><%=parent.getName() %></option>
							<%
								}
									}
							%>
						</select>
						<input type="button" name="queryBut" value="查询" onclick="queryDict()">
					</td>
					<td colspan="2" align="right" class=txlrow>&nbsp;<input type="button" value="删除" name="reflush" onclick="delDictionary()">
					&nbsp;<input type="button" value="刷新缓存" name="reflush" onclick="reflshCache()"></td>
				</tr>
				<tr align="center"  bgcolor="#799AE1">

					<td align="center" class="txlHeaderBackgroundAlternate">编码</td>
					<td align="center" class="txlHeaderBackgroundAlternate">名称</td>
					<td align="center" class="txlHeaderBackgroundAlternate">创建人</td>
					<td align="center" class="txlHeaderBackgroundAlternate">创建时间</td>
					<td align="center" class="txlHeaderBackgroundAlternate">排序号</td>
					<td align="center" class="txlHeaderBackgroundAlternate">选择</td>

				</tr>

				<%
					if(dictList.size()>0){
						for (int i = 0; i < dictList.size(); i++) {
							Dictionary dict = dictList.get(i);
				%>
				<tr bgcolor="#DEE5FA" id=<%=dict.getId() %>  onclick="setSelectedBgColoronclick(this);" style="cursor:hand">
					<td align="center" class="txlrow">&nbsp;<%=dict.getCode()%>
					</td>
					<td align=center class=txlrow>&nbsp;<%=dict.getName()%></td>
					<td align=center class=txlrow>&nbsp;<%=dict.getCreateBy()%></td>
					<td align=center class=txlrow>&nbsp;<%=dict.getCreateDate()%></td>
					<td align=center class=txlrow>&nbsp;<%=dict.getRemarks()%></td>
					<td align=center class=txlrow>&nbsp;<input type="checkbox" id="<%=dict.getId() %>" name="checkDict"></td>
				</tr>
				<%
					}
				%>
				<tr bgcolor="#DEE5FA">
					<td align=right class=txlrow colspan="6">
						<input type="hidden" name="currentPage" value="0">
						<%=CreatePageCode.create(curPage)%>
					
					</td>
				</tr>
				<%
					}else{
				%>
				<tr bgcolor="#DEE5FA">
					<td colspan=16 align=center class=txlrow>未找到数据</td>
				</tr>
				<%
					}
				%>
				
			</tbody>
		</table>
		</form>
	<script language="javascript">
function setSelectedBgColoronclick(curobj) {
		
		var tds=curobj.childNodes;  
	    for(var j=0; j<tds.length;j++)  
	    {  
	    	if(curobj.style.backgroundColor=="#FFB584"){
        		curobj.style.backgroundColor="#DEE5FA";
        	}else{
        		curobj.style.backgroundColor="#FFB584";
        	}
	    }  
		window.parent.phoneRightFrame.location.href="<%=path%>/dict/toUpdateDictionary/"+curobj.id;
	}
	function queryDict(){
		document.PageForm.submit();
	}
		function selectAll() {
			var arrObj = document.all;
			for (var i = 0; i < arrObj.length; i++) {

				if (typeof arrObj[i].type != "undefined"
						&& arrObj[i].type == 'checkbox')
					arrObj[i].checked = true;
			}
		}

		function unSelectAll() {
			var arrObj = document.all;
			for (var i = 0; i < arrObj.length; i++) {
				if (typeof arrObj[i].type != "undefined"
						&& arrObj[i].type == 'checkbox')
					arrObj[i].checked = false;
			}
		}
		
		function reflshCache(){
			var url ="<%=path%>/dict/refreshCache";
			window.open (url,"新增产品","height=400,width=600,top=100,left=400,toolbar=no,menubar=no,scrollbars=no,resizable=no,location=no,status=no"); 
		}
		
		function delDictionary(){
			var selectDict = document.getElementsByName("checkDict");
			var dictIds = "";
			if(selectDict.length>0){
				for(var i=0;i<selectDict.length;i++){
					if(selectDict[i].checked == true){
						dictIds += ","+selectDict[i].id;
					}
				}
			}
			if (!confirm("确认要删除?")) {
	            window.event.returnValue = false;
	        }
			var url = '<%=path%>/dict/deleteDictionary/'+dictIds.substring(1);
			window.open (url,"删除产品","height=600,width=800,top=100,left=400,toolbar=no,menubar=no,scrollbars=no,resizable=no,location=no,status=no"); 
		}
	</script>

</BODY>
</HTML>